import Cookies from 'js-cookie'
export default ({ route, store, redirect }) => {
  const path = route.path.replace(/^(\/\/)/, '/')
  const loggedIn = store.state.token && store.state.userInfo
  const token = store.state.token
  let needLogin = false
  // console.log('authenticated:::',loggedIn,store)
  if (/^\/user/.test(path)) {
    needLogin = true
  }

  if (needLogin && !loggedIn) {
    return redirect(`/`)
  }
}
